package com.baiyun.service.impl;

import com.baiyun.entity.Orders;
import com.baiyun.mapper.OrderMapper;
import com.baiyun.service.OrderService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.util.Date;
import java.util.List;

@Service
@RequiredArgsConstructor
@Slf4j
public class OrderServiceImpl implements OrderService {

    private final OrderMapper ordersMapper;
    /**
     * 查询所有订单
     * @return
     */
    @Override
    public List<Orders> selectAllOrder() {
        return ordersMapper.selectAllOrder();
    }

    @Override
    public void addOrder(Orders orders) {
        orders.setTimes(new Date());
        ordersMapper.addOrder(orders);
    }

    /**
     * 更新订单
     * @param orders
     */
    @Override
    public void updateOrder(Orders orders) {
        ordersMapper.updateOrder(orders);
    }

    /**
     * 删除订单
     * @param oid
     */
    @Override
    public void deleteOrder(Integer oid) {
        ordersMapper.deleteOrder(oid);
    }

    @Override
    public Orders selectById(Integer oid) {
        return ordersMapper.selectById(oid);
    }
}

